package com.campus.wall.ui;

import android.content.Intent;
import android.nfc.NfcAdapter;

import com.campus.wall.R;
import com.campus.wall.base.BaseMvpActivity;
import com.campus.wall.contract.MainContract;
import com.campus.wall.presenter.LoginPresenter;
import com.campus.wall.presenter.MainPresenter;
import com.self.baseutile.components.ToastUtils;

import butterknife.OnClick;

public class MainActivity extends BaseMvpActivity<MainPresenter> implements MainContract.View {

    protected NfcAdapter mNfcAdapter;

    @Override
    public int getLayoutId() {
        return R.layout.layout_main;
    }

    @Override
    public void initView() {
        mPresenter = new MainPresenter(this);
        mPresenter.attachView(this);
    }

    @OnClick(R.id.stuBtn)
    void stuBtn(){
        Intent intent = new Intent(this, StudentActivity.class);
        startActivity(intent);
    }

    @OnClick(R.id.nftBtn)
    void nftBtn(){
        mNfcAdapter = NfcAdapter.getDefaultAdapter(this);
        if(ifNFCUse() && mPresenter. checkPermission()){
            Intent intent = new Intent(this, NftActivity.class);
            startActivity(intent);
        }
    }
    protected Boolean ifNFCUse() {
        if (mNfcAdapter == null) {
            ToastUtils.Warnshow("该设备不支持NFC");
            return false;
        }
        if (mNfcAdapter != null && !mNfcAdapter.isEnabled()) {
            ToastUtils.Warnshow("请在系统设置中先启用NFC功能！");
            return false;
        }
        return true;
    }
    @OnClick(R.id.btn_ar)
    void btn_ar(){
        if(mPresenter. checkPermission()){
            Intent intent = new Intent(this, ArActivity.class);
            startActivity(intent);
        }else {
            ToastUtils.Errorshow("请给予相机权限");
        }
    }

    @OnClick(R.id.messageBtn)
    void messageBtn(){
        if(mPresenter. checkPermission()){
            Intent intent = new Intent(this, LeaveMessageActivity.class);
            startActivity(intent);
        }else {
            ToastUtils.Errorshow("请给予相机权限");
        }

    }
   @OnClick(R.id.fri_btn)
   void fri_btn(){
       Intent intent = new Intent(this, FriendActivity.class);
       startActivity(intent);
   }
   @OnClick(R.id.btn_map)
   void btn_map(){
       Intent intent = new Intent(this, SchoolMapActivity.class);
       startActivity(intent);
   }
    @Override
    public void onSuccess() {

    }
}
